package com.sls.nzdapplication.ui.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;

import com.sls.nzdapplication.R;
import com.sls.nzdapplication.ui.custom.base.MyBaseIconView;
import com.sls.nzdapplication.util.LogUtil;

public class AddFzxView extends MyBaseIconView {
    private static final String TAG = "AddFzxView";

    private OnAddFzxViewListener onAddFzxViewListener;


    public AddFzxView(Context context) {
        this(context, null);
    }

    public AddFzxView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public AddFzxView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if(onAddFzxViewListener == null){
                    return;
                }
                onAddFzxViewListener.onAddFzxViewClick();
            }
        });
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        LogUtil.d(TAG, "width=" + getMeasuredWidth() + ",height=" + getMeasuredHeight());
    }

    @Override
    public boolean createBackground() {
        setIconBackground(R.drawable.branch_box);
        return true;
    }

    @Override
    public boolean createIcon() {
        setBackgroundResource(R.drawable.icon_middle_selector);
        return true;
    }

    public void setAddFzxViewListener(OnAddFzxViewListener listener){
        if(listener != null){
            onAddFzxViewListener = listener;
        }
    }

    public interface OnAddFzxViewListener{

        void onAddFzxViewClick();
    }
}
